package com.djt.book_system.service.impl;

import com.djt.book_system.entity.Locations;
import com.djt.book_system.dao.LocationsDao;
import com.djt.book_system.service.LocationsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (Locations)表服务实现类
 *
 * @author makejava
 * @since 2021-05-19 10:48:12
 */
@Service("locationsService")
public class LocationsServiceImpl implements LocationsService {
    @Resource
    private LocationsDao locationsDao;

    /**
     * 通过ID查询单条数据
     *
     * @param uid 主键
     * @return 实例对象
     */
    @Override
    public Locations queryById(Integer uid) {
        return this.locationsDao.queryById(uid);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<Locations> queryAllByLimit(int offset, int limit) {
        return this.locationsDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param locations 实例对象
     * @return 实例对象
     */
    @Override
    public Locations insert(Locations locations) {
        this.locationsDao.insert(locations);
        return locations;
    }

    /**
     * 修改数据
     *
     * @param locations 实例对象
     * @return 实例对象
     */
    @Override
    public Locations update(Locations locations) {
        this.locationsDao.update(locations);
        return this.queryById(locations.getUid());
    }

    /**
     * 通过主键删除数据
     *
     * @param uid 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer uid) {
        return this.locationsDao.deleteById(uid) > 0;
    }
}
